﻿using ConnectorMsg;
using DatabaseMsg;
using DoudizhuMsg;
using Frameworks;
using GateMsg;
using LobbyMsg;
using RoomMsg;
using UnityEngine;

namespace DotNetClient
{
    public class GameHandler
    {
        // gate
        public static void onResConnect(Message data)
        {
            s2c_connect msg = data.decode<s2c_connect>();
            Debug.Log("onResConnect-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_GATE_CONNECT, msg);
        }

        // connector
        public static void onResLogin(Message data)
        {
            s2c_login msg = data.decode<s2c_login>();
            Debug.Log("onResLogin-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_CONNECTOR_LOGIN, msg);
        }

        public static void onResLogout(Message data)
        {
            s2c_logout msg = data.decode<s2c_logout>();
            Debug.Log("onResLogout-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_CONNECTOR_LOGOUT, msg);
        }

        public static void onResRegister(Message data)
        {
            s2c_register msg = data.decode<s2c_register>();
            Debug.Log("onResRegister-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_CONNECTOR_REGISTER, msg);
        }

        // lobby
        public static void onResMatch(Message data)
        {
            s2c_match msg = data.decode<s2c_match>();
            Debug.Log("onResMatch-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_LOBBY_MATCH, msg);
        }

        public static void onPushUserChat(Message data)
        {
            s2c_onChat msg = data.decode<s2c_onChat>();
            Debug.Log("onPushUserChat-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_LOBBY_ON_CHAT, msg);
        }

        public static void onPushUserEnter(Message data)
        {
            s2c_onEnter msg = data.decode<s2c_onEnter>();
            Debug.Log("onPushUserEnter-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_LOBBY_ON_ENTER, msg);
        }

        public static void onPushUserLeave(Message data)
        {
            s2c_onLeave msg = data.decode<s2c_onLeave>();
            Debug.Log("onPushUserLeave-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_LOBBY_ON_LEAVE, msg);
        }

        // room
        public static void onResRoomCreate(Message data)
        {
            s2c_create msg = data.decode<s2c_create>();
            Debug.Log("onResRoomCreate-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_ROOM_CREATE, msg);
        }

        public static void onResRoomJoin(Message data)
        {
            s2c_join msg = data.decode<s2c_join>();
            Debug.Log("onResRoomJoin-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_ROOM_JOIN, msg);
        }

        public static void onResRoomLeave(Message data)
        {
            s2c_leave msg = data.decode<s2c_leave>();
            Debug.Log("onResRoomLeave-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_ROOM_LEAVE, msg);
        }

        public static void onPushPlayerInfo(Message data)
        {
            s2c_onPlayerInfo msg = data.decode<s2c_onPlayerInfo>();
            Debug.Log("onPushPlayerInfo-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_ROOM_ON_PLAYER_INFO, msg);
        }

        public static void onPushPlayerLeave(Message data)
        {
            s2c_onPlayerLeave msg = data.decode<s2c_onPlayerLeave>();
            Debug.Log("onPushPlayerLeave-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_ROOM_ON_PLAYER_LEAVE, msg);
        }

        public static void onPushRoomMatch(Message data)
        {
            s2c_onMatch msg = data.decode<s2c_onMatch>();
            Debug.Log("onPushRoomMatch-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_ROOM_ON_MATCH, msg);
        }

        // database
        public static void onResGetUser(Message data)
        {
            s2c_getUser msg = data.decode<s2c_getUser>();
            Debug.Log("onResGetUser-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_DB_GET_USER, msg);
        }

        public static void onResRename(Message data)
        {
            s2c_rename msg = data.decode<s2c_rename>();
            Debug.Log("onResRename-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_DB_RENAME, msg);
        }

        public static void onResGetDoudizhuInfo(Message data)
        {
            s2c_getDoudizhuInfo msg = data.decode<s2c_getDoudizhuInfo>();
            Debug.Log("onResGetDoudizhuInfo-: " + msg);
            EventProxy.BroadcastEvent(Routes.C2S_DB_GET_DOUDIZHU_INFO, msg);
        }

        // doudizhu
        public static void onPushDoudizhuGameInit(Message data)
        {
            s2c_onGameInit msg = data.decode<s2c_onGameInit>();
            Debug.Log("onPushDoudizhuGameInit-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_DOUDIZHU_ON_GAME_INIT, msg);
        }

        public static void onPushDoudizhuGameStart(Message data)
        {
            s2c_onGameStart msg = data.decode<s2c_onGameStart>();
            Debug.Log("onPushDoudizhuGameStart-: " + msg);
            EventProxy.BroadcastEvent(Routes.S2C_DOUDIZHU_ON_GAME_START, msg);
        }
    }
}
